#!/bin/bash

source $DRAW_INI
source $DRAW_CFG

if [ ! -s "${1}.vcf.idx" ]; then
 echo "Incomplete VCF:" ${1}.vcf
 exit 100
fi

java -Xmx4g -jar $GATK \
  -T VariantFiltration \
  -R $REF_FASTA \
  --variant:VCF ${1}.vcf \
  -l INFO \
  --clusterWindowSize 10 \
  --filterName "HomopolymerRun"  --filterExpression "HRun>=4" \
  --filterName "QualByDepth"     --filterExpression "QD<5.0" \
  --filterName "StrandBias"      --filterExpression "FS>=20.0" \
  -o ${1}_filtered_nomask.vcf 

EXITSTATUS=$?


#if [ ! -s "${1}_filtered_nomask.vcf" ]; then exit 100;fi;

if [ ! -s "${1}_filtered_nomask.vcf.idx" ]
 then
  echo "vcf incomplete!"
  exit 100;
fi

exit $EXITSTATUS
